package app.web.hcartoon.analyse.year;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import cn.lily.com.container.data.Record;
import cn.lily.com.db.DBFactory;
import cn.lily.com.db.container.reader.DataTable;
/**
 * 里番分析控制
 * @author JiaJ
 * @date 2018年5月22日
 *
 */
public class HCartoonYearAnalyseControl {
	
	private Map<String, List<HCartoonEntity>> datas = new HashMap<String, List<HCartoonEntity>>();
	
	private void loadData(){
		
		String sql = "select CAN_DETAIL_ID,CAN_DETAIL_NAME,CAN_TIME "
				   + "from ${schema}.LEO_GALCAN_DETAIL_INFO "
				   + "order by CAN_TIME ";
		
		DataTable dataTable = DBFactory.getActionDB().executeQueryTable(sql);
		while(dataTable.next()){
			
			Record record = dataTable.getRecord();
			HCartoonEntity entity = new HCartoonEntity();
			entity.setRecord(record);
			
			String date = record.getString("CAN_TIME");
			String year = date.substring(0,4);
			
			List<HCartoonEntity> lists = new ArrayList<HCartoonEntity>();
			
			if(datas.containsKey(year)){
				lists = datas.get(year);
			}else{
				datas.put(year, lists);
			}
			
			lists.add(entity);
			
		}
		
	}
	
	public Map<String, List<HCartoonEntity>> getDatas(){
		this.loadData();
		return datas;
	}
	
}
